package org.jet.emall.rbac.transfer;


import org.jet.emall.rbac.dto.AdminRoleDTO;
import org.jet.emall.rbac.model.NewAdminRoleModel;
import org.jet.emall.rbac.model.UpdateAdminRoleModel;
import org.jet.emall.rbac.vo.AdminRoleVO;
import org.mapstruct.Mapper;

import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;


/**
 * @author xiaozai
 * @version 1.0
 * @date 2020-04-05 11:16
 */
@Mapper
public interface AdminRoleVoTransfer {
    AdminRoleVoTransfer INSTANCE = Mappers.getMapper(AdminRoleVoTransfer.class);

    /**
     * 将DTO转VO
     * @param dto
     * @return
     */
    AdminRoleVO toVo(AdminRoleDTO dto);

    /**
     * 将DTO集合转VO集合
     * @param dtoList
     * @return
     */
    List<AdminRoleVO> toVoList(List<AdminRoleDTO> dtoList);

    /**
     * 将新建角色模型转DTO
     * @param newRole
     * @return
     */
    @Mappings({
            @Mapping(target = "id",ignore = true),
            @Mapping(target = "modifiedTime",ignore = true),
            @Mapping(target = "deleted",ignore = true)
    })
    AdminRoleDTO toDto(NewAdminRoleModel newRole);

    /**
     * 将更新角色模型转DTO
     * @param updateRole
     * @return
     */
    @Mappings({
                    @Mapping(target = "modifiedTime", ignore = true),
                    @Mapping(target = "deleted", ignore = true)
    })
    AdminRoleDTO toDto(UpdateAdminRoleModel updateRole);
}
